Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/getproviders: Allow basedir for local search to be symlink #25692

Merged
merged 1 commit into from
Aug 18, 2020

Conversation

apparentlymart
Copy link
Contributor

The SearchLocalDirectory function was intentionally written to only support symlinks at the leaves so that it wouldn't risk getting into an infinite loop traversing intermediate symlinks, but that rule was also applying to the base directory itself.

It's pretty reasonable to put your local plugins in some location Terraform wouldn't normally search (e.g. because you want to get them from a shared filesystem mounted somewhere) and creating a symlink from one of the locations Terraform does search is a convenient way to help Terraform find those without going all in on the explicit provider installation methods configuration that is intended for more complicated situations.

To allow for that, here we make a special exception for the base directory, resolving that first before we do any directory walking.

In order to help with debugging a situation where there are for some reason symlinks at intermediate levels inside the search tree, we also now emit a WARN log line in that case to be explicit that symlinks are not supported there and to hint to put the symlink at the top-level if you want to use symlinks at all.

(The support for symlinks at the deepest level of search is not mentioned in this message because we allow it primarily for our own cache linking behavior.)

This fixes #25691.

@apparentlymart apparentlymart added bug cli v0.13 Issues (primarily bugs) reported against v0.13 releases labels Jul 28, 2020
@apparentlymart apparentlymart requested a review from a team July 28, 2020 17:28
@apparentlymart apparentlymart self-assigned this Jul 28, 2020
The SearchLocalDirectory function was intentionally written to only
support symlinks at the leaves so that it wouldn't risk getting into an
infinite loop traversing intermediate symlinks, but that rule was also
applying to the base directory itself.

It's pretty reasonable to put your local plugins in some location
Terraform wouldn't normally search (e.g. because you want to get them from
a shared filesystem mounted somewhere) and creating a symlink from one
of the locations Terraform _does_ search is a convenient way to help
Terraform find those without going all in on the explicit provider
installation methods configuration that is intended for more complicated
situations.

To allow for that, here we make a special exception for the base
directory, resolving that first before we do any directory walking.

In order to help with debugging a situation where there are for some
reason symlinks at intermediate levels inside the search tree, we also now
emit a WARN log line in that case to be explicit that symlinks are not
supported there and to hint to put the symlink at the top-level if you
want to use symlinks at all.

(The support for symlinks at the deepest level of search is not mentioned
in this message because we allow it primarily for our own cache linking
behavior.)
@codecov
Copy link

codecov bot commented Jul 28, 2020

Codecov Report

Merging #25692 into master will decrease coverage by 0.00%.
The diff coverage is 75.00%.

Impacted Files Coverage Δ
internal/getproviders/filesystem_search.go 62.99% <75.00%> (+0.80%) ⬆️
terraform/node_resource_plan.go 91.80% <0.00%> (-1.64%) ⬇️
terraform/evaluate.go 53.46% <0.00%> (-0.45%) ⬇️
dag/marshal.go 54.44% <0.00%> (+1.11%) ⬆️

Copy link
Contributor

@alisdair alisdair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good solution! 👍

I wish GitHub's diff UI was clearer about displaying symlinks, somehow…

@ghost
Copy link

ghost commented Oct 10, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug cli v0.13 Issues (primarily bugs) reported against v0.13 releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

root module's terraform.d not searched normally when plugins directory is symlink
2 participants